#include <iostream>
using namespace std;
 
int main()
{
    int T = 0;
    cin >> T;
    while(T--)
    {
        int h = 0;
        cin >> h;
        h--;
        int res = 1, last = 1;
        int tmp = h, resTmp = 1;
        while(h > 0)
        {
            // cout << last << " " << h << endl;
            if(h - last * 2 >= 0)
            {
                h -= last * 2;
                last *= 2;
            }
            else if(h - last >= 0)
            {
                h -= last;
            }
            else // 重新计数
            {
                h = tmp - 1;
                tmp--;
                res = resTmp + 1;
                resTmp++;
            }
            ++res;
        }
        cout << res << endl;
    }
    return 0;
}